﻿using System;
using System.Collections.Generic;
using System.Configuration;
using System.Linq;
using System.Reflection;
using System.Text;
using ARS.DataBase.Provider;

namespace ARS.Control.Factory
{
    public class DbFactory
    {
        //public static object CreateObjectNoCache(string AssemblyPath, string classNamespace)
        //{
        //    try
        //    {
        //        object objType = Assembly.Load(AssemblyPath).CreateInstance(classNamespace);
        //        return objType;
        //    }
        //    catch//(System.Exception ex)
        //    {
        //        //string str=ex.Message;// 记录错误日志
        //        return null;
        //    }

        //}

        /// <summary>
        /// 获取分隔符
        /// </summary>
        /// <returns></returns>
        public static string CreateDbParmCharacter()
        {
            switch (DataBase.Provider.DbFactory.dbType)
            {
                case DataBase.DbType.MYSQL:
                    return "?";
                    break;
                case DataBase.DbType.SQLSERVER:
                    return "@";
                    break;
            }
            return "";
        }



        private static IDataPagingProvider _dpProvider;
        /// <summary>
        /// DataPaging数据操作
        /// </summary>
        public static IDataPagingProvider DpProvider
        {
            get
            {
                if (_dpProvider == null)
                {
                    _dpProvider = ARS.DataBase.Provider.DataPagingProvider.GetInstance();
                }
                return _dpProvider;
            }
        }

        private static IDbProvider _dbProvider;
        /// <summary>
        /// DbProvider
        /// </summary>
        public static IDbProvider DbProvider
        {
            get
            {
                if (_dbProvider == null)
                {
                    _dbProvider = ARS.DataBase.Provider.DbProvider.GetInstance();
                }
                return _dbProvider;
            }
        }
    }
}
